package action.client;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import component.RunCmdComponent;
import constants.Constants;
import utils.GameUtils;

import java.io.File;

/**
 * @Auther syc.
 * @Date 2016/11/21 14:42.
 */
public class ClientRunningAction extends AnAction {
    @Override
    public void actionPerformed(AnActionEvent anActionEvent) {
        Application application = ApplicationManager.getApplication();
        RunCmdComponent component = application.getComponent(RunCmdComponent.class);

        String path = GameUtils.getPropertyValue(anActionEvent, Constants.CLIENT_PATH_PRO_NAME) + File.separator + "release";

        if(!GameUtils.isFileExist(path)) {
            return;
        }

        //update client
        component.commandsBatProccess(anActionEvent, path, "clientRunning" , Constants.CLIENT_BAT_NAME);
    }
}
